package com.store.controller;


import com.store.configure.Result;
import com.store.entity.User;
import com.store.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户相关
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    /**
     * 添加/修改
     */
    @RequestMapping("/updateUser")
    public Result<User> updateUser(@RequestBody User user) {
        return userService.updateUser(user);
    }

    /**
     * 删除
     */
    @RequestMapping("/delUser")
    public Result<User> delUser(@RequestBody User user) {
        return userService.delUser(user);
    }

    /**
     * 批量删除
     */
    @RequestMapping("/batchDelUser")
    public Result<User> batchDelUser(@RequestBody User user) {
        return userService.batchDelUser(user);
    }

    /**
     * 查询(不分页)
     */
    @RequestMapping("/queryUser")
    public Result<User> queryUser(@RequestBody User user) {
        return userService.queryUser(user);
    }

    /**
     * 查询(分页)
     */
    @RequestMapping("/queryUserByPage")
    public Result<User> queryUserByPage(@RequestBody User user) {
        return userService.queryUserByPage(user);
    }

    /**
     * 根据ID查询
     */
    @RequestMapping("/queryUserById")
    public Result<User> queryUserById(@RequestBody User user) {
        return userService.queryUserById(user);
    }

    @RequestMapping("/register")
    public Result<User> register(@RequestBody User user) {
        return userService.register(user);
    }

    @RequestMapping("/updatePassword")
    public Result<User> updatePassword(@RequestBody User user) {
        return userService.updatePassword(user);
    }
}

